//*************************************************************************************
//* 作    者： z hunter
//* 创建时间： 2021-09-08 09:06:31
//* 描    述： 动画播放

//* ************************************************************************************
using UnityEngine;
using UFrame.Tween;

public class TweenAgent : AgentContext<TweenAgent, TweenCtrl>, UFrame.ILateUpdate
{
    public bool Runing => true;
    public float Interval => 0;
    protected override object ManageBody => this;

    protected override void OnCreate()
    {
        base.OnCreate();
        UFrame.CodeAnimation.CodeAnimBase.tweenCtrl = AgentSelf;
    }
    public static void TweenMoveTo(GameObject target, Vector3 targetPos, float durection = 1)
    {
        var tween = TweenPosition.Create(target.transform, target.transform.position, targetPos, durection);
        tween.target = target.transform;
        Instance.StartTween(tween);
        tween.EnableTween();
    }

    public static void TweenMoveTo(GameObject body, Transform target, Vector3 hitPos, float durection = 1)
    {
        var tween = TweenLockMove.Create(body.transform, target.transform, hitPos, durection);
        Instance.StartTween(tween);
        tween.EnableTween();
    }

    public void OnLateUpdate()
    {
        Instance.Refresh();
    }
}